 {include file="public/header" /}
 {load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style>
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0;
        margin-top: 0
    }

    #title span {
        float: right;
        margin-left: 3px;
    }

    .search {
        margin-bottom: 0 !important;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }

</style>
 <body class="gray-bg">
 <div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
        {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='state'}{else /}asdlkjasd{/present}" href="{:url('jubao')}">全部</a>
                        <a class="btn btn-default btn-outline {eq name='state' value='0'}asdlkjasd{/eq}" href="{:url('jubao',['state'=>0])}">待处理</a>
                        <a class="btn btn-default btn-outline {eq name='state' value='2'}asdlkjasd{/eq}" href="{:url('jubao',['state'=>2])}">处理中</a>
                        <a class="btn btn-default btn-outline {eq name='state' value='1'}asdlkjasd{/eq}" href="{:url('jubao',['state'=>1])}">已处理</a>
                    </div>
                    <div class="fixed-table-toolbar">
                        <form method="get" action="" style="display: flex;">
                            <div class="pull-left search" style="display: flex;">
                                <div class="columns columns-right btn-group pull-left">
                                    <select class="form-control" name="search">
                                        <option value="user_id" {php}if(input(
                                        '?param.search')){if(input('param.search')=='user_id'){echo "selected";}
                                        }{/php}>ID</option>
                                        <option value="name" {php}if(input(
                                        '?param.search')){if(input('param.search')=='name'){echo "selected";}
                                        }{/php}>昵称</option>
                                        <option value="phone" {php}if(input(
                                        '?param.search')){if(input('param.search')=='phone'){echo "selected";}
                                        }{/php}>手机</option>
                                        <option value="report_user" {php}if(input(
                                        '?param.search')){if(input('param.search')=='report_user'){echo "selected";}
                                        }{/php}>被举报ID</option>
                                    </select>
                                </div>

                                <div class="pull-right search">
                                    <input class="form-control input-outline" type="text"
                                           {php}
                                           if(input('?param.name')){
                                    if(input('param.name')){
                                    echo "value='".input('name')."'";
                                    }

                                    }
                                    {/php}
                                    name="name" placeholder="搜索">
                                </div>

                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px"
                                            class="btn btn-default btn-outline" type="submit">搜索
                                    </button>
                                </div>

                                <input name="start" type="text" id="start" class="form-control layui-input" value="{present name='start'}{$start}{/present}" placeholder=" # 起始时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                                <input name="end" type="text" id="end" class="form-control layui-input" value="{present name='end'}{$end}{/present}" placeholder=" # 结束时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">

                                {php}
                                if(input('?param.name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('jubao')}">返回列表</a>
                                </div>
                                {php}
                                }
                                {/php}
                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                        <table data-toggle="table">
                            <thead>
                                <tr>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">类型</th>
                                    <th data-align="center">举报者</th>
                                    <th data-align="center">被举报者</th>
                                    <!--<th>联系方式</th>-->
                                    <th>描述</th>
                                    <th data-align="center">聊天记录</th>
                                    <th data-align="center">处理人</th>
                                    <th data-align="center">最新描述</th>
                                    <th data-align="center">时间</th>
                                    <th data-align="center">状态</th>
                                    <th data-align="center">管理</th>
                                </tr>
                            </thead> 
                            <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td id="id">{$v.id}</td>
                                    <?php $title = db('report_selected')->where('id', $v['report_selected_id'])->value('title'); ?>
                                    <td>{$title} {$v.jubaocount > 1 ? '<span style="color:#ff6600">多次投诉</span>' : ''}</td>
                                    <?php $name = db('user')->where('id', $v['user_id'])->value('name'); ?>
                                    <td><a onclick="member('{$v.user_id}')" style="color:#40BCF7">{$name}</a><br/>(ID：{$v.user_id})</td>
                                    <?php $report_name = db('user')->where('id', $v['report_user'])->value('name'); ?>
                                    <td><a onclick="member('{$v.report_user}')" style="color:#40BCF7">{$report_name}</a><br/>(ID：{$v.report_user})</td>
                                    <!--<td>{$v.user_hone}</td>-->
                                    <td>{$v['report_desc']}</td>
                                    <td><a onclick="chat('{$v.user_id}', '{$v.report_user}')" style="color:#40BCF7">查看</a></td>
                                    <td>{notempty name="v.admin_id"}{$v['admin_name']} ({$v['admin_id']}){/notempty}</td>
                                    <td>{$v['datalastest']['v']}</td>
                                    <td> 
                                        <span {php}if(date('Ymd')==date('Ymd',$v['time']))echo 'style="color: #ed5565"';{/php}>{$v.time|date='Y-m-d H:i:s',###}</span>
                                    </td>
                                    <td>
                                        {switch name="v.state"}
                                            {case value="0"}
                                            <span class="btn btn-default btn-xs">待处理</span>
                                            {/case}
                                            {case value="2"}
                                            <span class="btn btn-danger btn-xs">处理中</span>
                                            {/case}
                                            {default /}<span class="btn btn-primary btn-xs">已处理</span>
                                        {/switch}
                                    </td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                {switch name="$v.state"}
                                                    {case value="0"}
                                                        <li><a onClick="add('{:url('Article/dealJubao',['id'=>$v['id'],'url'=>-1])}')">开始处理</a></li>
                                                        <li><a onClick="shenhe({$v.id},'1')">结束处理</a></li>
                                                    {/case}
                                                    {case value="2"}
                                                        <li><a onClick="add('{:url('Article/dealJubao',['id'=>$v['id'],'url'=>-1])}')">补充处理信息</a></li>
                                                        <li><a onClick="shenhe({$v.id},'1')">结束处理</a></li>
                                                    {/case}
                                                    {case value="1"}
                                                        <li><a onClick="add('{:url('Article/dealJubao',['id'=>$v['id'],'url'=>-1])}')">补充处理信息</a></li>
                                                        <li><a onclick="del('{$v.id}')">删除</a></li>
                                                    {/case}
                                                {/switch}
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                            </tbody>
                        </table>
                        </form>
                    </div>
                </div>  
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-12 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
$(document).ready(function(){
    layui.use(['laydate'], function(){
        var laydate = layui.laydate;

        laydate.render({
            elem: '#start' //指定元素
            ,type: 'datetime'
            ,trigger: 'click'
        });

        laydate.render({
            elem: '#end' //指定元素
            ,type: 'datetime'
            ,trigger: 'click'
        });
    })
});
function del(id){
    swal_del(id,"{:url('jubaoDel')}")
}
function huifu(id){
    layer.prompt({title: '回复用户', formType: 2,maxlength:255}, function(pass, index){
        if(pass){
            ajaxFun('post','{:url('jubaoHuifu')}',{content:pass,id:id},'json',function(ret,err){
                if(ret){
                    if(ret.ret){
                        layer.msg(ret.ret)
                        layer.close(index)
                        setTimeout(function(){
                            location.reload() 
                        },1500)
                    }else{
                        layer.msg(ret.err)
                    }
                }
            })
        }
    });
}

function shenhe(id,value){
    ajaxFun("post","{:url('jubaoadd')}",{id:id},'json',function(ret){
        if(ret){
            if(ret.ret){
                layer.msg(ret.ret)
                window.location.reload()
            }else{
                layer.msg(ret.err)
            }
        }else{
            swal_msg("错误",ret,"error");
        }
    })
}

function member(id)
{
    layui.use('layer', function(){
        var layer = layui.layer;
        layer.open({
            title :'预览',
            area: ['100%', '100%'],
            type: 2,
            content: '{:url("member/index")}?search=id&name='+id
        });
    });
}

function chat(user_id, to_user)
{
    layui.use('layer', function(){
        var layer = layui.layer;
        layer.open({
            title :'预览',
            area: ['100%', '100%'],
            type: 2,
            content: '{:url("usertalk/records")}?type=2&search=userid&name='+user_id+','+to_user
        });
    });
}
</script>
 